﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.Collections.Specialized;
using Meraz.Core.Model;


namespace Meraz.Core.Parsers
{
    public class DailyKosXmlParser : XmlBlogParser
    {
        public DailyKosXmlParser():base()
        {
            this.BlogKey = BlogKeyType.DailyKos;
        }
        internal override List<string> GetAliases(XmlDocument doc)
        {
            List<string> aliases = new List<string>();
            foreach (XmlNode item in doc.SelectNodes("div/[@class='byline']/a"))
            {
                string byline = CollapseWhitespace(item.InnerText);
                aliases.Add(byline);
            }
            return aliases;
        }
        internal override string GetBody(XmlDocument doc)
        {
            return CollapseWhitespace(doc.SelectSingleNode("div/[@class='entry']").InnerText);
        }
        internal override DateTime GetPubDate(XmlDocument doc)
        {
            string pubdate = doc.SelectSingleNode(@"h4/[@class='date']").InnerText.Replace("at ", "");
            return DateTime.Parse(pubdate);
        }
    }
}
